﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Echiquier
{
    public class PionSet
    {
        #region Attributs
        //singleton
        private static PionSet _singleton;

        //Pions
        private Pion _blankPion;
        private Pion _cavalier;
        private Pion _roi;

        private Dictionary<int, Pion> _pions;
        #endregion

        #region Constructeur
        private PionSet()
        {
            _pions = new Dictionary<int, Pion>();
            _blankPion = new Pion();
            _cavalier = new Pion("Cavalier", Color.Blue);
            _roi = new Pion("Roi", Color.Red);
            _pions.Add(_blankPion.Id, _blankPion);
            _pions.Add(_cavalier.Id, _cavalier);
            _pions.Add(_roi.Id, _roi);
        }
        #endregion

        #region Proprietes

        public Pion this[int id]
        {
            get { return _pions[id]; }
        }

        public int Count
        {
            get { return _pions.Count; }
        }

        #endregion

        #region Methodes
        public static PionSet GetSingleton()
        {
            if (_singleton == null)
                _singleton = new PionSet();
            return _singleton;
        }

        public Pion CreatePion(string name, Color c)
        {
            Pion p = new Pion(name, c);
            _pions.Add(p.Id, p);
            return p;
        }

        public Pion CreatePion(Pion p)
        {
            _pions.Add(p.Id, p);
            return p;
        }

        #endregion
    }
}
